package com.learn.test;

import org.apache.commons.math3.linear.Array2DRowRealMatrix;
import org.apache.commons.math3.linear.RealMatrix;

/**
 * @描述
 * @创建人 zengqingdong
 * @创建时间 2020/7/2 12:19
 */
public class MathMethod {

    public static void main(String[] args){
        double a[][] = new double[7][7];
        double b[][] = new double[7][1];
        a[0][0]=5;
        a[0][1]=3;
        a[0][2]=4;
        a[0][3]=4;
        a[0][4]=2;
        a[0][5]=2;
        a[0][6]=1;
        a[1][0]=3;
        a[1][1]=3;
        a[1][2]=3;
        a[1][3]=2;
        a[1][4]=1;
        a[1][5]=1;
        a[1][6]=0;
        a[2][0]=4;
        a[2][1]=3;
        a[2][2]=4;
        a[2][3]=3;
        a[2][4]=1;
        a[2][5]=2;
        a[2][6]=0;
        a[3][0]=4;
        a[3][1]=2;
        a[3][2]=3;
        a[3][3]=4;
        a[3][4]=2;
        a[3][5]=2;
        a[3][6]=1;
        a[4][0]=2;
        a[4][1]=1;
        a[4][2]=1;
        a[4][3]=2;
        a[4][4]=2;
        a[4][5]=1;
        a[4][6]=1;
        a[5][0]=2;
        a[5][1]=1;
        a[5][2]=2;
        a[5][3]=2;
        a[5][4]=1;
        a[5][5]=2;
        a[5][6]=0;
        a[6][0]=1;
        a[6][1]=0;
        a[6][2]=0;
        a[6][3]=1;
        a[6][4]=1;
        a[6][5]=0;
        a[6][6]=1;
//构建b二维数组
        b[0][0] = 2.0;
        b[1][0] = 0.0;
        b[2][0] = 0.0;
        b[3][0] = 4.0;
        b[4][0] = 4.5;
        b[5][0] = 0.0;
        b[6][0] = 5.0;
        RealMatrix matrixA = new Array2DRowRealMatrix(a);
        System.out.println("创建的数组为：\t"+matrixA);
        RealMatrix matrixB = new Array2DRowRealMatrix(b);
        System.out.println("创建的数组为：\t"+matrixB);

        double testmatrix[][] = new double[7][1];
        testmatrix[0][0] = 1.0;
        testmatrix[1][0] = 2.0;
        testmatrix[2][0] = 3.0;
        testmatrix[3][0] = 4.0;
        testmatrix[4][0] = 5.0;
        testmatrix[5][0] = 6.0;
        testmatrix[6][0] = 7.0;

        RealMatrix testmatrix1 = new Array2DRowRealMatrix(testmatrix);
        System.out.println("两个矩阵相乘后的结果为：\t"+matrixA.multiply(matrixB) );
    }


}
